<?php
$this->headTitle($this->translator('bizprofile_user_registerenterprise_title'));
$this->headLink()
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.all.css')
    ->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.ui/themes/base/ui.datepicker.css');

$this->headScript()
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
    ->appendFile($this->APP_STATIC_SERVER . '/js/jquery.ui/ui.datepicker.js');
?>

<div class="t_bizprofile_register">
    <h2><?php echo $this->translator('bizprofile_user_registerenterprise_title'); ?></h2>

    <?php if($this->is_full):?>
        <div style="color:#FF0000;"><?php echo $this->translator('enterprise_register_is_full');?></div>
    <?php else:?>
    <div class="message"><?php echo $this->flashMessenger(); ?></div>
    <form method="post" action="<?php echo $this->url(array(), 'bizprofile_user_register_enterprise'); ?>" id="registerEnterpriseForm">
        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_company_name_vn'); ?>:</label>
            <font style="color:red; padding-left:5px;"> (*)</font>
            <input type="text" id="company_name_vn" name="company_name_vn" style="width: 200px" />
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_company_name_en'); ?>:</label>
            <input type="text" id="company_name_en" name="company_name_en" style="width: 200px" />
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_professtions'); ?>:</label>
            <div style="padding: 5px 5px 5px 0px; overflow:auto;width:400px;">
                <?php for ($i = 0; $i < count($this->professions); $i++) : ?>
                <div style="width:195px; float:left; font-size:7pt;">
                    <input type="checkbox" id="professions_id[]" name="professions_id[]" value="<?php echo $this->professions[$i]->professions_id; ?>" >&nbsp;&nbsp;<?php echo $this->professions[$i]->professions_name; ?><br>
                </div>
                <?php endfor; ?>
            </div>
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_currency'); ?>:</label>
            <select id="currency" name="currency" style="width:200px">
                <option value=""><?php echo $this->translator('bizprofile_user_registerenterprise_choose_currency'); ?></option>
                <?php foreach($this->currency as $row):?>
                <option value="<?php echo $row->currency_name;?>"><?php echo $row->currency_name;?></option>
                <?php endforeach;?>
            </select>
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_contact_email'); ?>:</label>
            <input type="text" id="contact_email" name="contact_email" style="width: 200px" />
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_contact_tel'); ?>:</label>
            <font style="color:red; padding-left:5px;"> (*)</font>
            <input type="text" id="contact_tel" name="contact_tel" style="width: 200px" />
        </div>

         <div class="clearfix">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_contact_fax'); ?>:</label>
            <font style="color:red; padding-left:5px;"> (*)</font>
            <input type="text" id="contact_fax" name="contact_fax" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_contact_address'); ?>:</label>
            <input type="text" id="contact_address" name="contact_address" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label style="line-height:15px;height:1px">&nbsp;</label>
            <span style="font-weight:bold;"><?php echo $this->translator('bizprofile_user_registerenterprise_account');?> VND:</span>
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_name'); ?>:</label>
            <input type="text" id="bank_name_vnd" name="bank_name_vnd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_account'); ?>:</label>
            <input type="text" id="bank_account_vnd" name="bank_account_vnd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_account_owner'); ?>:</label>
            <input type="text" id="bank_account_owner_vnd" name="bank_account_owner_vnd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label style="line-height:15px;height:1px">&nbsp;</label>
            <span style="font-weight:bold;"><?php echo $this->translator('bizprofile_user_registerenterprise_account');?> USD:</span>
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_name'); ?>:</label>
            <input type="text" id="bank_name_usd" name="bank_name_usd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_account'); ?>:</label>
            <input type="text" id="bank_account_usd" name="bank_account_usd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_bank_account_owner'); ?>:</label>
            <input type="text" id="bank_account_owner_usd" name="bank_account_owner_usd" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_registration_number'); ?>:</label>
            <input type="text" id="registration_number" name="registration_number" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_registration_date'); ?>:</label>
            <input type="text" id="registration_date" name="registration_date" style="width: 200px" />
        </div>

        <div class="clearfix t_a_bottom">
            <label><?php echo $this->translator('bizprofile_user_registerenterprise_registration_city'); ?>:</label>
            <input type="text" id="registration_city" name="registration_city" style="width: 200px" />
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('user_register_security_code'); ?>:</label>
            <img src="<?php echo $this->APP_STATIC_SERVER ?>/images/captcha/<?php echo $this->captchaId ?>.png" alt="Captcha code" /><br>
        </div>

        <div class="clearfix">
            <label><?php echo $this->translator('user_register_verify_code'); ?></label>
            <font style="color:red; padding-left:5px;"> (*)</font>
            <input name="captcha[input]" type="text" />
            <input name="captcha[id]" type="hidden" value="<?php echo $this->captchaId ?>" />
        </div>

        <div class="clearfix">
            <label>&nbsp;</label>
            <?php echo $this->tokenElement; ?>
            <button type="submit"><span><?php echo $this->translator('user_register_submit_button'); ?></span></button>
            <button type="reset"><span><?php echo $this->translator('bizprofile_user_register_reset_button'); ?></span></button>
        </div>
    </form>
    <?php endif;?>
</div>

<script type="text/javascript">

$(document).ready(function() {

    /**
    * Create datepicker instances
    */
    $('#registration_date').datepicker({ dateFormat: 'dd/mm/yy' });
    
    // EDIT - STAR : KHANH; 25/04/2011; Kiem tra so dien thoai co dau +
    $.validator.addMethod('check_fonenumber', function(value) {
		var str = value;
		var the_char = str.charAt(0);
		
		if(the_char=="+")
		{
			str = str.split(' ').join(''); ;	// Remove Spaces
			var len = str.length;
			
			for(i=1; i<len; i++) // bat dau tu ky tu sau dau "+"
			{
				if(str[i]=="0")
				{
					
				}
				else if(!parseInt(str[i]))				
				{ return false; }	
			}	
		}
		else
		{ return false;	}
	
		return true;
	});
	// EDIT - STOP

    $('#registerEnterpriseForm').validate({
        rules: {
            company_name_vn: {
                required: true,
                maxlength: 255
            },
            company_name_en:{
                maxlength: 255
            },
            contact_tel:{
            	check_fonenumber: true
            },
            contact_fax:{
            	check_fonenumber: true
            }
            /*contact_email:{
                required: true,
                email:true
            },
            registration_number:{
                required: true
            },
            registration_date:{
                required: true
            },
            registration_city:{
                required: true
            },
            currency:{
                required: true,
            },
            contact_tel:{
                required: true,
                number: true
            },
            contact_fax:{
                required: true,
                number: true
            },
            contact_address:{
                required: true
            }
            ,
            bank_name_vnd:{
                required: true
            }
            ,
            bank_account_vnd:{
                required: true
            }
            ,
            bank_account_owner_vnd:{
                required: true
            }*/
        },
        messages: {
            company_name_vn: {
                required: "<?php echo $this->translator('bizprofile_user_registerenterprise_company_name_vn_required'); ?>",
                maxlength: "<?php echo $this->translator('bizprofile_user_registerenterprise_company_name_vn_maxlength'); ?>"
            },
            company_name_en: "<?php echo $this->translator('bizprofile_user_registerenterprise_company_name_en_maxlength'); ?>",
            
            contact_tel: {
            	check_fonenumber: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_tel_invalid_number'); ?>",
            },
            contact_fax: {
            	check_fonenumber: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_fax_invalid_number'); ?>",
            }
            
            /*contact_email: {
                required: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_email_required'); ?>",
                email: "<?php echo $this->translator('bizprofile_user_registerenterprise_invalid_email'); ?>"
            },
            registration_number: "<?php echo $this->translator('bizprofile_user_registerenterprise_registration_number_required'); ?>",
            registration_date: "<?php echo $this->translator('bizprofile_user_registerenterprise_registration_date_required'); ?>",
            registration_city: "<?php echo $this->translator('bizprofile_user_registerenterprise_registration_city_required'); ?>",
            currency: "<?php echo $this->translator('bizprofile_user_registerenterprise_currency_required'); ?>",
            contact_tel: {
                required: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_tel_required'); ?>",
                number: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_tel_invalid_number'); ?>"
            },
            contact_fax: {
                required: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_fax_required'); ?>",
                number: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_fax_invalid_number'); ?>"
            },
            contact_address: "<?php echo $this->translator('bizprofile_user_registerenterprise_contact_address_required'); ?>",
            bank_name_vnd: "<?php echo $this->translator('bizprofile_user_registerenterprise_bank_name_required'); ?>",
            bank_account_vnd: "<?php echo $this->translator('bizprofile_user_registerenterprise_bank_account_required'); ?>",
            bank_account_owner_vnd: "<?php echo $this->translator('bizprofile_user_registerenterprise_bank_account_owner_required'); ?>",*/
        }
    });
});
</script>
